<template>
    <div>
        <Form ref="form" :model="formData" :label-width="120">
            <FormItem label="FEDEX:">
                <Input v-model="formData.Fedex"></Input>
            </FormItem>
            <FormItem label="UPS:">
                <Input v-model="formData.UPSnum"></Input>
            </FormItem>
        </Form>
        <div class="text-right">
            <Button type="primary" @click="submit">确定</Button>
            <Button class="margin-left-10" @click="close">关闭</Button>
        </div>
    </div>
</template>
<script>
import { HttpSaveControl } from '@/service/api/views'

export default {
    props:['id'],
    data(){
        return {
            formData:{
                Fedex:'',
                UPSnum:'',
            },
            dataaa:null,
        }
    },
    mounted(){
        if(this.id.labellist){
            this.dataaa = JSON.parse(this.id.labellist);
            this.formData.Fedex = this.dataaa.FEDEX;
            this.formData.UPSnum = this.dataaa.UPS;
        }
    },
    methods:{
        async submit(){
            let astr = {
                FEDEX:this.formData.Fedex,
                UPS:this.formData.UPSnum
            }
            HttpSaveControl({
                id:this.id.id,
                labelLimit:JSON.stringify(astr)
            }).then(res=>{
                this.$Message.success(res.message);
                this.$emit('on-update');
                this.close()
            })
        },
        close(){
            this.$emit('on-close')
        }
    }
}
</script>